#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int n, total;

int sum(vector<int>& nums, int limit) {
    int n = nums.size(), ans = 0;
    for (int i = 0; i < n; i++) {
        if (nums[i] <= limit) {
            ans += nums[i];
        } else {
            ans += limit;
        }
    }
    return ans;
}

int main() {
    cin >> n;
    vector<int> records(n);
    for (int i = 0; i < n; i++) cin >> records[i];
    cin >> total;
    if (accumulate(records.begin(), records.end(), 0) <= total) {
        cout << -1 << endl;
        return 0;
    }
    sort(records.begin(), records.end());
    int l = records[0], r = records[n - 1], limit;
    while (l <= r) {
        limit = l + (r - l) / 2;
        if (sum(records, limit) > total) {
            r = limit - 1;
        } else {
            l = limit + 1;
        }
    }
    cout << r << endl;
    return 0;
}

/*
intput:
6
3 3 8 7 10 15
40
output:
9

intput:
5
3 3 5 7 9
40
output:
-1

*/